//
//  CoursesSearchTableViewCell.m
//  ClassRoom
//
//  Created by apple on 12-12-2.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "CoursesSearchTableViewCell.h"

@implementation CoursesSearchTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 48)];
        image1.image = [UIImage imageNamed:@"searchViewCellbg"];
        self.backgroundView = image1;
        
        // Initialization code
        _image = [[UIImageView alloc] initWithFrame:CGRectMake(5, 7.5, 50, 40)];
        _image.backgroundColor = [UIColor clearColor];
        _image.image = [UIImage imageNamed:@"201087153734339.jpeg"];
        [self addSubview:_image];
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(70, 6, 220, 20)];
        _title.backgroundColor = [UIColor clearColor];
//        _title.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
        _title.font = [UIFont systemFontOfSize:14];
        [self addSubview:_title];
/*        
        _class = [[UILabel alloc] initWithFrame:CGRectMake(150, 8, 145, 18)];
        _class.backgroundColor = [UIColor clearColor];
        _class.font = [UIFont systemFontOfSize:11];
        _class.textAlignment = UITextAlignmentCenter;
        [self addSubview:_class];

        _address = [[UILabel alloc] initWithFrame:CGRectMake(70, 31, 120, 12)];
        _address.backgroundColor = [UIColor clearColor];
        _address.font = [UIFont systemFontOfSize:11];
        [self addSubview:_address];
        
        _price = [[UILabel alloc] initWithFrame:CGRectMake(170, 31, 100, 12)];
        _price.backgroundColor = [UIColor clearColor];
        _price.font = [UIFont systemFontOfSize:11];
        [self addSubview:_price];
 */
        _address = [[UILabel alloc] initWithFrame:CGRectMake(70, 31, 270, 12)];
        _address.backgroundColor = [UIColor clearColor];
        _address.font = [UIFont systemFontOfSize:11];
        [self addSubview:_address];
        
        UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(295, 18.5, 13, 20)];
        image.image = [UIImage imageNamed:@"Arrowhead_Green"];
        [self addSubview:image];
    }
    return self;
}

- (void)setCellData:(NSDictionary *)data{
/*
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"company"]) {
        _title.text = [[data objectForKey:@"information"] objectForKey:@"company"];
    }
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"courseName"]) {
        _class.text = [[data objectForKey:@"information"] objectForKey:@"courseName"];
    }
    
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"area"]) {
        _address.text = [NSString stringWithFormat:@"地址：%@",[[data objectForKey:@"information"] objectForKey:@"area"]];
    }
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"price"]) {
        NSNumber * price = [[data objectForKey:@"information"] objectForKey:@"price"];
        _price.text = [NSString stringWithFormat:@"价格：%.f元",[price floatValue]];
    }
     
*/
    NSString *title = nil;
    NSString *class = nil;
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"company"]) {
        title = [[data objectForKey:@"information"] objectForKey:@"company"];
    }
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"courseName"]) {
        class = [[data objectForKey:@"information"] objectForKey:@"courseName"];
    }
    _title.text = [NSString stringWithFormat:@"%@        %@",title,class];
    
    NSString *address = nil;
    NSString *priceStr = nil;
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"area"]) {
        address = [NSString stringWithFormat:@"地址：%@",[[data objectForKey:@"information"] objectForKey:@"area"]];
    }
    if (nil!=[[data objectForKey:@"information"] objectForKey:@"price"]) {
        NSNumber * price = [[data objectForKey:@"information"] objectForKey:@"price"];
        priceStr = [NSString stringWithFormat:@"价格：%.f元",[price floatValue]];
    }
    
    _address.text = [NSString stringWithFormat:@"%@        %@",address,priceStr];
    
//    _title.text = @"新东方英语";
//    _class.text = @"英语四级冲刺班包过班好吗";
//    _address.text = @"地点：海淀区人大";
//    _price.text = @"价格：111111元";
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
-(void)dealloc{
    [_image release];
    [_title release];
    [_address release];
    [_class release];
    [_price release];
    
    [super dealloc];
}

@end
